package com.song.eureka.client.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 
 * @description : 实现/dc请求处理接口，通过DiscoveryClient对象，在日志中打印出服务实例的相关内容
 * @date        : 2018-08-08 16:32
 * @author      : leoSong
 *
 */
@RestController
public class DcController {
  @Autowired
  DiscoveryClient discoveryClient;

  
  /**
   * 为了触发服务降级逻辑，我们可以将服务提供者eureka-client的逻辑加一些延迟，比如：
   * @date    : 2018-08-10 16:38
   * @author  : leoSong
   * @return
   * @throws InterruptedException 
   */
  @GetMapping("/dc")
  public String dc() throws InterruptedException {
      // Thread.sleep(5000L);
      String services = "Services: " + discoveryClient.getServices();
      System.out.println(services);
      return services;
  }

}
